/**
 * 
 */
package com.yidin.lsc;

import android.os.Bundle;

import com.baidu.mapapi.BMapManager;
import com.baidu.mapapi.GeoPoint;
import com.baidu.mapapi.MapController;
import com.baidu.mapapi.MapView;

/**
 * 手机横屏时出现商家地图
 * @author cola
 *
 */
public class BaiduMap extends BaseActivity{
	private BMapManager mBMapMan;
	private MapView mMapView;
	private MapController mMapController;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.fullscreenbaidumap);
		onCreateMap();
		mMapView = (MapView) findViewById(R.id.fullbmapsView);
		mMapView.setBuiltInZoomControls(true);  //设置启用内置的缩放控件
		 
		mMapController = mMapView.getController();  // 得到mMapView的控制权,可以用它控制和驱动平移和缩放
		GeoPoint point = new GeoPoint((int) (32.115 * 1E6),
		        (int) (113.404 * 1E6));  //用给定的经纬度构造一个GeoPoint，单位是微度 (度 * 1E6)
		mMapController.setCenter(point);  //设置地图中心点
		mMapController.setZoom(12);    //设置地图zoom级别
	}
	
	@Override
	public void init() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void refresh(Object... param) {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	protected void onDestroy() {
		if (mBMapMan != null) {
			mBMapMan.destroy();
			mBMapMan = null;
		}
		super.onDestroy();
	}

	@Override
	protected void onPause() {
		if (mBMapMan != null) {
			mBMapMan.stop();
		}
		super.onPause();
	}

	@Override
	protected void onResume() {
		if (mBMapMan != null) {
			mBMapMan.start();
		}
		super.onResume();
	}

	public void setMap() {
		super.initMapActivity(mBMapMan);
	}

	public void onCreateMap() {
		mBMapMan = new BMapManager(getApplication());
		mBMapMan.init("D7E3959A574AC544C10485C2C998B5D45ACC9F7F", null);
		super.initMapActivity(mBMapMan);
	}

	public void onDestroyMap() {
		if (mBMapMan != null) {
			mBMapMan.destroy();
			mBMapMan = null;
		}
	}
}
